<template>
	<div>
		<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media" v-for="item in newList" :key="item.id">
					<!--在这里要进入每个不同页面的列表数目，所以要加每个页面的id来区别，并且注意路径是字符串形式-->
					<router-link :to="'/home/newsinfo/' + item.id">
						<img class="mui-media-object mui-pull-left"  :src="item.img_url">
						<div class="mui-media-body">
							<h1>{{item.title}}</h1>
							<p class='mui-ellipsis'>
								<!--过滤器       时间格式化-->
								<span>{{item.add_time| dataFormat}}</span>
								<span>点击{{item.click}}次</span>
							</p>
						</div>
					</router-link>
				</li>
				
			</ul>
	</div>
</template>

<script>
	import {Toast} from "mint-ui"
	export default{
		name:"newslist",
		data(){
			return{
				newList:[]
			}
		},
		created() {
			this.getNewList()
		},
		methods:{
			getNewList() {
				this.$http.get('api/getnewslist').then(result=>{
					//判断是否拿到数据，成功，状态为0
					if(result.body.status==0){
						console.log(result.body.message)
						this.newList=result.body.message
					}else{
						Toast("请求失败")
					}
					
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.mui-table-view {
		li{
			h1{
				text-align: left;
				font-size: 12px;
			}
			.mui-ellipsis{
				font-size: 12px;
				text-align: left;
				color:cornflowerblue;
				display: flex;
				justify-content: space-between;
			}
		}
	}
</style>